<template>
  <div id="dataStatistics">
    <div class="left-Chart">
      <div class="businessData">
        <span class="middle-tag"> 业务数据 </span>
        <div class="orderNum">
          <p>订单量</p>
          <p>{{ order }}</p>
          <p>
            昨日环比: &nbsp;&nbsp;<span style="color: #41cb79; font-weight: 600"
              >{{ sequential1 | arrow }}%</span
            >
          </p>
        </div>
        <div class="speakPeople">
          <p>讲解人数</p>
          <p>{{ interpretation }}</p>
          <p>
            昨日环比: &nbsp;&nbsp;<span style="color: #c32c2c; font-weight: 600"
              >{{ sequential2 | arrow }}%</span
            >
          </p>
        </div>
        <div class="speakcost">
          <p>讲解费</p>
          <p>{{ countPay.dayOrder }}</p>
          <p>
            昨日环比: &nbsp;&nbsp;<span style="color: #41cb79; font-weight: 600"
              >{{ sequential3 | arrow }}%</span
            >
          </p>
        </div>
        <div class="rent">
          <p>租赁费</p>
          <p>{{ countPay.dayOrder }}</p>
          <p>
            昨日环比: &nbsp;&nbsp;<span style="color: #41cb79; font-weight: 600"
              >{{ sequential4 | arrow }}%</span
            >
          </p>
        </div>
      </div>
      <p class="middle-nav">本日数据</p>
      <div class="todayData">
        <div class="touristsData">
          <span class="title">游客数据</span>
          <div>
            <el-touriestData :peopelNum="interpretation"></el-touriestData>
          </div>
        </div>
        <div class="boxDataShow">
          <span class="title">岗亭数据</span>
          <div>
            <el-boxData></el-boxData>
          </div>
        </div>
        <div class="guideOnlineStatistics">
          <span class="title">导游在线统计</span>
          <div>
            <p>
              占比:
              {{ count.proportion ? Number(count.proportion) : 0 }}%
            </p>
            <el-progress
              :text-inside="true"
              :stroke-width="24"
              :percentage="count.proportion ? Number(count.proportion) : 0"
              status="success"
            ></el-progress>
            <p>
              <span>导游总量:{{ count.allTour }}人</span>
              <span
                >当前在线导游
                <span style="color: #f4cd49; font-weight: bold">{{
                  count.onlineTour
                }}</span
                >人</span
              >
            </p>
          </div>
        </div>
      </div>
    </div>
    <div class="middle-Chart">
      <h1>景区大数据可视化平台</h1>
      <p>日期/时间: {{ time }}</p>
      <div class="realTime">
        <p>实时监控图</p>
        <div class="map">
          <div class="numberOfOnline">
            <span>讲解游客在线数: {{ interpretation }}</span>
            <span
              >当前导游在线数: {{ count.onlineTour }}/{{ count.allTour }}</span
            >
          </div>
          <div class="mapbaidu">
            <el-baiduMap></el-baiduMap>
          </div>
        </div>
      </div>
      <div class="totalData">
        <p>整体数据统计</p>
        <div class="Order">
          <el-dataStatistics></el-dataStatistics>
        </div>
      </div>
    </div>
    <div class="right-Chart">
      <div class="boxData">
        <span class="title">岗亭数据信息</span>
        <div>
          <!-- <img src="../../assets/images/gangting.png" alt="" /> -->
        </div>
      </div>
      <div class="touristSatisfaction">
        <span class="title">游客满意度评价信息</span>
        <div>
          <!-- <img src="../../assets/images/manyidu.png" alt="" /> -->
        </div>
      </div>
      <div class="thisMonth">本月数据统计</div>
    </div>
  </div>
</template>

<script>
import boxData from "./boxData.vue";
import touriestData from "./touriestData.vue";
import dataStatistics from "./dataStatistics.vue";
import baiduMap from "../baidumap.vue";
import { getOnlinePeople } from "@/network/api/dataState/index";
import {
  useTheMiddlePlane,
  getOrderNum,
  getPayNum,
} from "@/network/api/dataState/index";

export default {
  name: "dataStatistics",
  data() {
    return {
      up: "↑",
      down: "↓",
      sequential1: "23",
      sequential2: "2",
      sequential3: "23",
      sequential4: "13",
      sequentialColor: 0,
      time: "",
      timer: "",
      interpretation: 0, //讲解人数
      count: 0,
      order: 0,
      countPay: 0,
    };
  },
  components: {
    "el-boxData": boxData,
    "el-touriestData": touriestData,
    "el-dataStatistics": dataStatistics,
    "el-baiduMap": baiduMap,
  },
  filters: {
    arrow(val) {
      if (val > 10) {
        return "↑ " + val;
      } else {
        return "↓ " + val;
      }
    },
  },
  created() {
    this.getNowTime();
    this.getOnlieData();
    this.getUserData();
    this.getOrderData();
    this.getPayData();
  },
  methods: {
    getNowTime() {
      this.timer = setInterval(() => {
        let myData = new Date();
        let h = myData.getHours(); //获取时
        h = h >= 10 ? h : "0" + h;
        let m = myData.getMinutes(); //获取分
        m = m >= 10 ? m : "0" + m;
        let s = myData.getSeconds(); //获取秒
        s = s >= 10 ? s : "0" + s;
        let y = myData.getFullYear(); //获取年
        let mon = myData.getMonth() + 1; //获取月
        mon = mon >= 10 ? mon : "0" + mon;
        let d = myData.getDate(); //获取日
        // console.log(y + "-" + mon + "-" + d + "-" + h + "-" + m + "-" + s);
        this.time = `${y}年${mon}月${d}日 ${h}:${m}:${s}`;
      }, 1000);
    },
    async getOnlieData() {
      let result = await getOnlinePeople();
      this.count = result.data.data.countOnlineVO;
      console.log(result, 888);
    },
    async getUserData() {
      let result = await useTheMiddlePlane();
      this.interpretation = result.data.data.countUseNum;
    },
    async getOrderData() {
      let result = await getOrderNum();
      this.order = result.data.data.countOrderNum;
    },
    async getPayData() {
      let result = await getPayNum();
      this.countPay = result.data.data.countOrderPayVO;
    },
  },
};
</script>

<style scoped lang="scss">
#dataStatistics {
  width: 100%;
  background-color: #000;
  display: flex;
  .left-Chart {
    width: 300px;
    padding: 10px;
    .businessData {
      width: 100%;
      height: 200px;
      box-sizing: border-box;
      position: relative;
      .middle-tag {
        display: inline-block;
        width: 50px;
        height: 50px;
        color: #fff;
        background-color: #0f346d;
        border-radius: 50%;
        text-align: center;
        line-height: 50px;
        font-size: 12px;
        position: absolute;
        top: 38%;
        left: 42%;
      }
      > div {
        width: 49.3%;
        height: 49.3%;
        display: inline-block;
        border: 1px solid #929292;
        box-sizing: border-box;
        > p:first-of-type {
          text-align: center;
          color: #fff;
          margin: 10px 0;
        }
        > p:nth-of-type(2) {
          text-align: center;
          color: #d9c832;
          font-size: 18px;
          font-weight: bold;
          margin: 10px 0;
        }
        > p:last-of-type {
          color: #fff;
          text-align: center;
          font-size: 12px;
        }
      }
    }
    .middle-nav {
      background-color: #051d3f;
      text-align: center;
      color: #a9bbe6;
      font-size: 14px;
      padding: 5px;
    }
    .todayData {
      height: 414px;
      border: 1px solid #929292;
      > div {
        height: 33.3%;
        border-bottom: 1px solid #515151;
      }
      .title {
        font-size: 12px;
        color: #fff;
        font-weight: bold;
      }
      .touristsData {
        > div {
          width: 100%;
          height: 83%;
        }
      }
      .boxDataShow {
        > div {
          width: 100%;
          height: 83%;
        }
      }
      .guideOnlineStatistics {
        position: relative;
        > .title {
          font-weight: bold;
          font-size: 14px;
          position: absolute;
        }
        > div {
          margin-top: 20px;
          padding: 0 20px;
          > p:first-of-type {
            text-align: right;
            font-weight: bold;
            color: #3dc072;
            font-size: 14px;
            padding-bottom: 10px;
          }
          > p:last-of-type {
            color: #ccc;
            font-size: 14px;
            display: flex;
            justify-content: space-between;
            padding-top: 10px;
          }
        }
      }
    }
  }
  .middle-Chart {
    width: 650px;

    h1 {
      color: #ffeb3b;
      font-size: 2.1em;
      text-align: center;
    }
    > p {
      color: #fff;
      text-align: center;
      padding: 10px;
    }
    .realTime {
      padding: 0 5px;
      > p {
        background-color: #051d3f;
        color: #fff;
        padding: 5px 0;
        text-align: center;
      }
      .map {
        border-top: none;
        border: 1px solid #929292;
        height: 320px;
        position: relative;
        .numberOfOnline {
          position: absolute;
          top: 0;
          left: 0;
          display: flex;
          flex-direction: column;
          margin: 10px;
          z-index: 9999999;
          span {
            font-size: 14px;
            color: #dba800;
            font-weight: bold;
          }
        }
      }
    }
    .totalData {
      margin-top: 16px;
      padding: 0 5px;
      > p {
        background-color: #051d3f;
        color: #fff;
        padding: 5px 0;
        text-align: center;
      }
      .Order {
        border-top: none;
        border: 1px solid #929292;
        height: 170px;
      }
    }
  }
  .right-Chart {
    width: 300px;

    padding: 10px 0 10px 10px;
    position: relative;
    .title {
      color: #fff;
      font-weight: bold;
      font-size: 12px;
    }
    .boxData {
      height: 55%;
      border: 1px solid #929292;
      padding: 10px;
      > div {
        width: 100%;
        height: 90%;
        background-image: url(../../assets/images/gangting.png);
        background-position: center center;
        background-size: contain;
        background-repeat: no-repeat;
      }
    }
    .touristSatisfaction {
      height: 37.5%;
      border: 1px solid #929292;
      padding: 25px 10px 0;
      > div {
        width: 100%;
        height: 90%;
        background-image: url(../../assets/images/manyidu.png);
        background-position: center center;
        background-size: contain;
        background-repeat: no-repeat;
      }
    }
    .thisMonth {
      position: absolute;
      color: #a9bbe6;
      top: 55.5%;
      right: 12%;
      width: 200px;
      padding: 5px 0;
      background-color: #051d3f;
      text-align: center;
    }
  }
}
</style>